local M = {
  "akinsho/bufferline.nvim",
  enabled = true,
  version = "*",
  dependencies = {
    "nvim-tree/nvim-web-devicons",
  },
}

M.config = function()
  vim.opt.termguicolors = true
  require("bufferline").setup {
    options = {
      -- mode = "tabs",
      -- separator_style = "slant",

      -- 需要 lsp 支持
      diagnostics = "nvim_lsp",
      -- bufferline 中同时显示错误和警告 需要 lsp 中的支持
      -- Optional, show LSP error icon
      ---@diagnostic disable-next-line: unused-local
      diagnostics_indicator = function(count, level, diagnostics_dict, context)
        local indicator = ""
        for level, number in pairs(diagnostics_dict) do
          -- local symbol = (level == "error" and " ") or (level == "warning" and " ") or "󰌵" -- " " " " " " "󰌵 "
          local symbol = (level == "error" and "   ") or (level == "warning" and "   ") or (level == "info" and "   ") or (level == "hint" and " ⚑ ") -- " " " " " " "󰌵 "
          indicator = indicator .. number .. symbol
        end
        return indicator
      end,
    },
  }

  -- gt 切换到下一个，gT切换到上一个
  vim.keymap.set("n", "gt", "<cmd>BufferLineCycleNext<CR>")
  vim.keymap.set("n", "gT", "<cmd>BufferLineCyclePrev<CR>")
end

return M
